package com.bw.service.impl;

import com.bw.dao.GoodsDao;
import com.bw.domain.Brand;
import com.bw.domain.Goods;
import com.bw.service.GoodsService;
import com.bw.vo.GoodsVO;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class GoodsServiceImpl implements GoodsService {
    @Autowired
    GoodsDao goodsDao;
    @Override
    public Integer add(Goods goods) {
        return goodsDao.add(goods);
    }

    @Override
    public List<Brand> listBrands() {
        return goodsDao.listBrands();
    }

    @Override
    public PageInfo<Goods> listGoods(GoodsVO goodsVO, Integer pageNum, Integer pageSize) {
        PageHelper.startPage(pageNum,pageSize);
        List<Goods> list = goodsDao.listGoods(goodsVO);
        return new PageInfo<>(list);
    }

    @Override
    public Goods get(Integer id) {
        return goodsDao.get(id);
    }

    @Override
    public Integer update(Goods goods) {
        return goodsDao.update(goods);
    }

    @Override
    public Integer deleteById(Integer id) {
        return goodsDao.deleteById(id);
    }

    @Override
    public Integer deleteBatch(Integer[] gids) {
        return goodsDao.deleteBatch(gids);
    }
}
